package com.zzy.springbook.service;

import com.zzy.springbook.dao.BookDao;
import com.zzy.springbook.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * 下面的这个就是我们的业务逻辑层：处理业务逻辑
 */

import java.util.List;


@Service
public class BookService {


    @Autowired
    private BookDao bookDao;


    /**
     * 根据数据层的返回结果对于数据进行处理
     * @return
     */
    public List<BookInfo> getBookInfoList(){
        //BookDao bookDao = new BookDao();
        List<BookInfo> bookInfos = bookDao.mockBookData();
        for(BookInfo bookInfo : bookInfos) {
            if(bookInfo.getState()==1){
                bookInfo.setStateCN("可借阅");
            }else if(bookInfo.getState()==2){
                bookInfo.setStateCN("不可借阅");
            }
        }
        return bookInfos;
    }

}
